<? 
	if(isset($_POST['btngo']))
	{
		require("required/dbconnect.php");
		$main_cat=$_POST['main_cat'];
		$sub_cat=$_POST['sub_cat'];
		$pageno=$_POST['pageno'];
		header("Location:product_viewall.php?page=$pageno&main_cat=$main_cat&sub_cat=$sub_cat");
	}
	
	$title="View All Birthday Voucher"; 
	$pageid="1";
	$accessid="a00";
	
	require("required/dbconnect.php"); 
	require("required/function.php");
	require("required/header.php");
	
	checkAccess("allow_gift_management",1);
	
?>
<script src="required/js/jquery-1.4.2.js"></script>
<script src="required/js/common_javascript.js"></script>
<?

		
	if(!empty($_GET['action']))
	{
		switch($_GET['action'])
		{
			case 1:
				$msg="<div class='dw_success'>Data Added!</div>";
				break;
			case 2:
				$msg="<div class='dw_failed'>Voucher code already exist,update failed!</div>";
				break;
			case 3:
				$msg="<div class='dw_success'>Data Updated</div>";
				break;	
			default:
				$msg="";
				break;
		}
		echo "<script>displayMsg('divMsg')</script>";	
	}else{
		$msg="";
	}
	
	$get_bv=mysql_query("select * from os_discount_voucher where is_birthday_voucher=1")or die(mysql_error());
	
	
?>
<table width="100%">


<td align="left" valign="top">
	<div class="title"><?= $title ?></div>
	    <div id="divMsg"><?= $msg ?></div>
    <table width="100%" cellpadding="2" cellspacing="1">
		<? if(mysql_num_rows($get_bv)==0){ ?>
		<tr>
		 <td height="200" valign="middle" colspan="8" align="center">
			<font color="#FF0000">- No record found -</font><br>
		
		 </td>
		</tr>
		<? }else{ ?>
		
		<tr class="table_header" >
			<Td width="9%">No</Td>
			<td width="22%">Voucher Name</td>
			<td width="25%">Voucher Code</td>
			<td width="30%">Duration</td>
			<td width="14%">Action</td>
		</tr>
		<?
			$no=1;
			while($a=mysql_fetch_array($get_bv))
			{
				if($no%2==0)
				{
					$class1="table_item_even";
					$class2="table_item_odd";
				}
				else
				{
					$class1="table_item_odd";
					$class2="table_item_even";
				}
				
				
				
		?>	
		  <tr height="20" valign="top" class="<?= $class1 ?>"  onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='<?= $class1 ?>'">
			<td><?= $no ?></td><Td> <?= $a['voucher_name'] ?></Td>
            <Td> <?= $a['voucher_code'] ?></Td>
            <td>from <?= $a['start_date'] ?> to <?= $a['end_date'] ?></td>
            <td align="center">
            	<a href="bv_edit.php?id=<?= $a['id'] ?>"><img src="images/icons/edit.gif" border="0" /></a>
            	<a href="bv_delete.php?id=<?= $a['id'] ?>"><img src="images/icons/delete.gif" border="0" /></a>
            </td>
		</Tr>
		<? $no++;}} ?>
	</table>
    <input type="button" value="Add" onclick="window.open('bv_add.php','_self')" />
	</td>
</table>

<? require("required/footer.php"); ?>

